<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        var a = prompt('请输入要判断的年份');
        if (!isNaN(a) && a > 0){
            if (year(a)) alert(a + '是闰年');
            else alert( a + '是平年');
        } else {
            alert('输入有误');
        }
        function year(y){
            if ((y % 4 == 0 && y % 100 != 0 )||( y % 400 == 0)){
                return true;
            }
            return false;
        }

    </script>
</body>
</html>